package br.com.mmm.javacenter.framework.reflection.injectors;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;

import br.com.mmm.javacenter.framework.annotations.InjectorComponent;
import br.com.mmm.javacenter.framework.reflection.ReflectionFacade;

@InjectorComponent({
	BigDecimal.class
})
public class BigDecimalInjector implements Injector{
	private static NumberFormat df = DecimalFormat.getInstance(new Locale("pt","BR"));


	public void inject(ReflectionFacade rf, String field, Object value) {
		
		try{	
			BigDecimal obj = new BigDecimal(df.parse(value.toString()).toString());
			rf.set(field, obj);
		}catch(ParseException e){
			throw new RuntimeException(e);
		}

	}
	
}
